package com.yeyks.account.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.yeyks.account.dal.domain.SysLog;
import com.yeyks.account.dal.dao.SysLogMapper;
import com.yeyks.account.service.SysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeyks.common.base.Arguments;
import com.yeyks.common.base.PageResult;
import com.yeyks.common.param.SysLogParam;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * <p>
 * 系统日志 服务实现类
 * </p>
 *
 * @author yun
 * @since 2019-06-25
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {

    /**
     * 操作日志列表查询
     *
     * @param param
     * @return
     */
    @Override
    public PageResult<SysLog> myList(SysLogParam param) {
        QueryWrapper<SysLog> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc(SysLog.CREATE_DATE);
        if (Arguments.strNotNull(param.getUserName())) {
            wrapper.like(SysLog.USERNAME, param.getUserName());
        }
        if (Arguments.strNotNull(param.getOperator())) {
            wrapper.like(SysLog.OPERATION, param.getOperator());
        }
        if (Arguments.strNotNull(param.getParamValue())) {
            wrapper.like(SysLog.PARAMS, param.getParamValue());
        }
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<SysLog> sysLogs = baseMapper.selectList(wrapper);
        return PageResult.getPageResult(sysLogs);
    }
}
